﻿using System;
using System.IO;
using System.Windows.Forms;
using Styx;
using Styx.Common;

namespace TeleportDetector
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void txtMessage_TextChanged(object sender, EventArgs e)
        {
            MIRsettings.Instance.Message = txtMessage.Text;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            txtMessage.Text = MIRsettings.Instance.Message;
            numLeashDistance.Value = MIRsettings.Instance.LeashDistance;
            txtCharacterName.Text = MIRsettings.Instance.CharacterName;
            MIRsettings.Instance.Load();
        }

        private void numLeashDistance_ValueChanged(object sender, EventArgs e)
        {
            MIRsettings.Instance.LeashDistance = (int) numLeashDistance.Value;
        }

        private void txtCharacterName_TextChanged(object sender, EventArgs e)
        {
            MIRsettings.Instance.CharacterName = txtCharacterName.Text;
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            MIRsettings.Instance.Save();
        }

        private void btnAuthorize_Click(object sender, EventArgs e)
        {
            using (var streamWriter = new StreamWriter("Plugins\\TeleportDetector\\hotspot.txt"))
            {
                streamWriter.WriteLine(StyxWoW.Me.Location);
                Logging.Write("Authorized Stuck...");
            }
        }
    }
}
